home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2007 April / CM 04-2007 CD2.iso / cdmenu / modules / menu.dat / scripts / %3Cdefault package%3E / GWCollapsiblePaneClass.as < prev    next >
Encoding:
Text File  |  2006-01-15  |  12.4 KB  |  356 lines

  1. _global.GWCollapsiblePaneClass = function()
  2. {
  3.    super.init(GWCollapsiblePaneClass);
  4. };
  5. GWCollapsiblePaneClass.prototype = new GWBaseClass();
  6. Object.registerClass("GWCollapsiblePaneClass",GWCollapsiblePaneClass);
  7. GWCollapsiblePaneClass.prototype.init = function()
  8. {
  9.    this.startIndex = this.startIndex || 0;
  10.    this.width = Math.round(this._width);
  11.    this.height = Math.round(this._height);
  12.    this._xscale = this._yscale = 100;
  13.    this.pane_mc._visible = 0;
  14.    var _loc3_ = [];
  15.    var _loc4_ = this.labels.length;
  16.    var _loc2_ = 0;
  17.    while(_loc2_ < _loc4_)
  18.    {
  19.       _loc3_[_loc2_] = {};
  20.       _loc3_[_loc2_].label = this.labels[_loc2_];
  21.       _loc3_[_loc2_].data = this.data[_loc2_];
  22.       _loc2_ = _loc2_ + 1;
  23.    }
  24.    this.setDataProvider(_loc3_);
  25. };
  26. GWCollapsiblePaneClass.prototype.getDataProvider = function()
  27. {
  28.    var _loc3_ = [];
  29.    var _loc4_ = this.panes.length || 0;
  30.    var _loc2_ = 0;
  31.    while(_loc2_ < _loc4_)
  32.    {
  33.       _loc3_[_loc2_] = {};
  34.       _loc3_[_loc2_].label = this.panes[_loc2_].label;
  35.       _loc3_[_loc2_].data = this.panes[_loc2_].data;
  36.       if(this.panes[_loc2_].icon)
  37.       {
  38.          _loc3_[_loc2_].icon = this.panes[_loc2_].icon;
  39.       }
  40.       _loc2_ = _loc2_ + 1;
  41.    }
  42.    return _loc3_;
  43. };
  44. GWCollapsiblePaneClass.prototype.setDataProvider = function(d)
  45. {
  46.    var _loc3_ = this.panes.length || 0;
  47.    var _loc2_ = 0;
  48.    while(_loc2_ <= _loc3_)
  49.    {
  50.       this["pane" + _loc2_ + "_mc"].removeMovieClip();
  51.       _loc2_ = _loc2_ + 1;
  52.    }
  53.    this.panes = [];
  54.    _loc3_ = d.length;
  55.    _loc2_ = 0;
  56.    while(_loc2_ < _loc3_)
  57.    {
  58.       this.addPane(d[_loc2_]);
  59.       _loc2_ = _loc2_ + 1;
  60.    }
  61.    if(this.startIndex != -1)
  62.    {
  63.       this.expand(this.startIndex);
  64.    }
  65.    this.setSize(this.width);
  66. };
  67. GWCollapsiblePaneClass.prototype.addPane = function()
  68. {
  69.    var _loc7_ = typeof arguments[0] != "object" ? {data:arguments[0],label:arguments[1]} : arguments[0];
  70.    var _loc4_ = this.panes.length;
  71.    this.panes.push(_loc7_);
  72.    var _loc3_ = "pane" + _loc4_ + "_mc";
  73.    this.pane_mc.duplicateMovieClip(_loc3_,_loc4_);
  74.    this[_loc3_].paneID = _loc4_;
  75.    this[_loc3_]._y = this["pane" + (_loc4_ - 1) + "_mc"]._y + (!this["pane" + (_loc4_ - 1) + "_mc"].expanded ? this["pane" + (_loc4_ - 1) + "_mc"].titlebar_mc._height : this["pane" + (_loc4_ - 1) + "_mc"]._height);
  76.    this.setPaneLabel(this.panes[_loc4_].label,_loc4_);
  77.    this.setPaneContent(this.panes[_loc4_].data,_loc4_);
  78.    this.drawBox("mask_mc",-1,0,0,this.width - 4,this[_loc3_].titlebar_mc._height,0,100,this[_loc3_].label_mc);
  79.    this[_loc3_].label_mc.setMask(this[_loc3_].label_mc.mask_mc);
  80.    this[_loc3_].titlebar_mc.useHandCursor = false;
  81.    this[_loc3_].titlebar_mc.onRollOver = function()
  82.    {
  83.       var _loc3_ = new TextFormat();
  84.       _loc3_.color = this._parent._parent.fontcolor_on;
  85.       this._parent.label_mc.label_txt.setTextFormat(_loc3_);
  86.       if(this._parent.arrow_mc.over_mc != undefined)
  87.       {
  88.          for(var _loc2_ in this._parent.arrow_mc)
  89.          {
  90.             this._parent.arrow_mc[_loc2_]._visible = 0;
  91.          }
  92.          if(this._parent.expanded)
  93.          {
  94.             this._parent.arrow_mc.down_over_mc._visible = 1;
  95.          }
  96.          else
  97.          {
  98.             this._parent.arrow_mc.over_mc._visible = 1;
  99.          }
  100.       }
  101.       else
  102.       {
  103.          var _loc4_ = new Color(this._parent.arrow_mc);
  104.          _loc4_.setRGB(this._parent._parent.fontcolor_on);
  105.       }
  106.    };
  107.    this[_loc3_].titlebar_mc.onDragOut = this[_loc3_].titlebar_mc.onReleaseOutside = this[_loc3_].titlebar_mc.onRollOut = function()
  108.    {
  109.       var _loc3_ = new TextFormat();
  110.       _loc3_.color = this._parent._parent.fontcolor;
  111.       this._parent.label_mc.label_txt.setTextFormat(_loc3_);
  112.       if(this._parent.arrow_mc.over_mc != undefined)
  113.       {
  114.          for(var _loc2_ in this._parent.arrow_mc)
  115.          {
  116.             this._parent.arrow_mc[_loc2_]._visible = 0;
  117.          }
  118.          if(this._parent.expanded)
  119.          {
  120.             this._parent.arrow_mc.down_mc._visible = 1;
  121.          }
  122.          else
  123.          {
  124.             this._parent.arrow_mc.out_mc._visible = 1;
  125.          }
  126.       }
  127.       else
  128.       {
  129.          var _loc4_ = new Color(this._parent.arrow_mc);
  130.          _loc4_.setRGB(this._parent._parent.fontcolor);
  131.       }
  132.    };
  133.    this[_loc3_].titlebar_mc.onRelease = function()
  134.    {
  135.       if(this._parent.expanded)
  136.       {
  137.          this._parent._parent.collapse(this._parent.paneID);
  138.       }
  139.       else
  140.       {
  141.          if(this._parent._parent.mode == "Accordion")
  142.          {
  143.             this._parent._parent.collapseAll();
  144.          }
  145.          this._parent._parent.expand(this._parent.paneID);
  146.       }
  147.       this.onRollOver();
  148.    };
  149. };
  150. GWCollapsiblePaneClass.prototype.collapse = function(id)
  151. {
  152.    if(id == undefined)
  153.    {
  154.       return this.collapseAll();
  155.    }
  156.    var _loc3_ = this["pane" + id + "_mc"];
  157.    if(_loc3_ == undefined || id == undefined)
  158.    {
  159.       return undefined;
  160.    }
  161.    for(var _loc2_ in _loc3_.arrow_mc)
  162.    {
  163.       _loc3_.arrow_mc[_loc2_]._visible = false;
  164.    }
  165.    _loc3_.content_mc._visible = _loc3_.expanded = false;
  166.    _loc3_.arrow_mc.out_mc._visible = true;
  167.    var _loc5_ = this.panes.length;
  168.    var _loc2_ = id;
  169.    while(_loc2_ < _loc5_)
  170.    {
  171.       this["pane" + _loc2_ + "_mc"]._y = this["pane" + (_loc2_ - 1) + "_mc"]._y + (!this["pane" + (_loc2_ - 1) + "_mc"].expanded ? 0 : this.getPaneSize(_loc2_ - 1).height) + (this["pane" + (_loc2_ - 1) + "_mc"].titlebar_mc.height || this["pane" + (_loc2_ - 1) + "_mc"].titlebar_mc._height);
  172.       _loc2_ = _loc2_ + 1;
  173.    }
  174.    this.onCollapse(id);
  175. };
  176. GWCollapsiblePaneClass.prototype.expand = function(id)
  177. {
  178.    if(id == undefined)
  179.    {
  180.       return this.expandAll();
  181.    }
  182.    var _loc3_ = this["pane" + id + "_mc"];
  183.    if(_loc3_ == undefined)
  184.    {
  185.       return undefined;
  186.    }
  187.    for(var _loc2_ in _loc3_.arrow_mc)
  188.    {
  189.       _loc3_.arrow_mc[_loc2_]._visible = false;
  190.    }
  191.    _loc3_.arrow_mc.down_mc._visible = _loc3_.content_mc._visible = _loc3_.expanded = true;
  192.    var _loc5_ = this.panes.length;
  193.    var _loc2_ = id;
  194.    while(_loc2_ <= _loc5_)
  195.    {
  196.       this["pane" + (_loc2_ + 1) + "_mc"]._y = this["pane" + _loc2_ + "_mc"]._y + (!this["pane" + _loc2_ + "_mc"].expanded ? 0 : this.getPaneSize(_loc2_).height) + (this["pane" + _loc2_ + "_mc"].titlebar_mc.height || this["pane" + _loc2_ + "_mc"].titlebar_mc._height);
  197.       _loc2_ = _loc2_ + 1;
  198.    }
  199.    this.onExpand(id);
  200. };
  201. GWCollapsiblePaneClass.prototype.expandAll = function()
  202. {
  203.    var _loc3_ = this.panes.length;
  204.    var _loc2_ = 0;
  205.    while(_loc2_ < _loc3_)
  206.    {
  207.       if(!this["pane" + _loc2_ + "_mc"].expanded)
  208.       {
  209.          this.expand(_loc2_);
  210.       }
  211.       _loc2_ = _loc2_ + 1;
  212.    }
  213. };
  214. GWCollapsiblePaneClass.prototype.collapseAll = function()
  215. {
  216.    var _loc3_ = this.panes.length;
  217.    var _loc2_ = 0;
  218.    while(_loc2_ < _loc3_)
  219.    {
  220.       if(this["pane" + _loc2_ + "_mc"].expanded)
  221.       {
  222.          this.collapse(_loc2_);
  223.       }
  224.       _loc2_ = _loc2_ + 1;
  225.    }
  226. };
  227. GWCollapsiblePaneClass.prototype.getSize = function()
  228. {
  229.    var _loc4_ = undefined;
  230.    var _loc3_ = this.panes.length;
  231.    var _loc2_ = 0;
  232.    while(_loc2_ < _loc3_)
  233.    {
  234.       _loc4_ += this["pane" + _loc2_ + "_mc"].titlebar_mc._height + (!this["pane" + _loc2_ + "_mc"].expanded ? 0 : this["pane" + _loc2_ + "_mc"].content_mc.base_mc.height);
  235.       _loc2_ = _loc2_ + 1;
  236.    }
  237.    return {width:this.width,height:_loc4_};
  238. };
  239. GWCollapsiblePaneClass.prototype.setSize = function(w)
  240. {
  241.    var _loc0_ = null;
  242.    w = this.width = Math.round(w);
  243.    var _loc3_ = this.panes.length;
  244.    var _loc2_ = 0;
  245.    while(_loc2_ < _loc3_)
  246.    {
  247.       this.setPaneSize(w,0,_loc2_);
  248.       if(this.getPaneContent(_loc2_).data_txt)
  249.       {
  250.          this.loadText(this.panes[_loc2_].data,_loc2_);
  251.       }
  252.       _loc2_ = _loc2_ + 1;
  253.    }
  254.    _loc2_ = 0;
  255.    while(_loc2_ < _loc3_)
  256.    {
  257.       this.width = Math.max(this.width,this.getPaneSize(_loc2_).width);
  258.       if(this.getPaneSize(_loc2_).width < this.width)
  259.       {
  260.          this.setSize(this.width);
  261.          break;
  262.       }
  263.       _loc2_ = _loc2_ + 1;
  264.    }
  265. };
  266. GWCollapsiblePaneClass.prototype.getPaneContent = function(id)
  267. {
  268.    if(this["pane" + id + "_mc"].content_mc.holder_mc == undefined)
  269.    {
  270.       this["pane" + id + "_mc"].content_mc.createEmptyMovieClip("holder_mc",1);
  271.    }
  272.    return this["pane" + id + "_mc"].content_mc.holder_mc;
  273. };
  274. GWCollapsiblePaneClass.prototype.loadText = function(t, id)
  275. {
  276.    if(t.length)
  277.    {
  278.       this["pane" + id + "_mc"].content_mc.holder_mc.removeMovieClip();
  279.       this["pane" + id + "_mc"].content_mc.createEmptyMovieClip("holder_mc",1);
  280.       this["pane" + id + "_mc"].content_mc.holder_mc.createTextField("data_txt",1,this.pad,this.pad,this.width - this.pad * 2,0);
  281.       var _loc3_ = new TextFormat();
  282.       _loc3_.font = this.font;
  283.       _loc3_.size = this.fontsize;
  284.       _loc3_.color = this.textcolor;
  285.       this["pane" + id + "_mc"].content_mc.holder_mc.data_txt.setNewTextFormat(_loc3_);
  286.       this["pane" + id + "_mc"].content_mc.holder_mc.data_txt.autoSize = "left";
  287.       this["pane" + id + "_mc"].content_mc.holder_mc.data_txt.selectable = false;
  288.       this["pane" + id + "_mc"].content_mc.holder_mc.data_txt.wordWrap = true;
  289.       this["pane" + id + "_mc"].content_mc.holder_mc.data_txt.html = true;
  290.       if(this.useEmbedFonts)
  291.       {
  292.          this["pane" + id + "_mc"].content_mc.holder_mc.data_txt.embedFonts = true;
  293.       }
  294.       this["pane" + id + "_mc"].content_mc.holder_mc.data_txt.htmlText = "<font color=\'#" + this.textcolor.toString(16) + "\' size=\'" + this.fontsize + "\' face=\'" + this.font + "\'>" + t + "</font>";
  295.       this.setPaneSize(this.width,0,id);
  296.       this.expand(id);
  297.    }
  298. };
  299. GWCollapsiblePaneClass.prototype.setPaneContent = function(m, id)
  300. {
  301.    this["pane" + id + "_mc"].content_mc.holder_mc.removeMovieClip();
  302.    this["pane" + id + "_mc"].content_mc.attachMovie(m,"holder_mc",1,{_x:this.pad,_y:this.pad});
  303.    if(!this["pane" + id + "_mc"].content_mc.holder_mc)
  304.    {
  305.       this.loadText(m,id);
  306.    }
  307.    this.collapse(id);
  308. };
  309. GWCollapsiblePaneClass.prototype.getPaneSize = function(id)
  310. {
  311.    return {width:this["pane" + id + "_mc"].content_mc.base_mc.width || this["pane" + id + "_mc"].content_mc.base_mc._width,height:this["pane" + id + "_mc"].content_mc.base_mc.height || this["pane" + id + "_mc"].content_mc.base_mc._height};
  312. };
  313. GWCollapsiblePaneClass.prototype.setPaneSize = function(w, h, id)
  314. {
  315.    if(this.resizeToFit)
  316.    {
  317.       this.width = w = Math.max(w,Math.max(this["pane" + id + "_mc"].label_mc._x + this["pane" + id + "_mc"].label_mc._width + 4,(this["pane" + id + "_mc"].content_mc.holder_mc._width || 0) + this.pad * 2));
  318.    }
  319.    h = h || (this["pane" + id + "_mc"].content_mc.holder_mc._height || 0) + this.pad * 2;
  320.    if(this["pane" + id + "_mc"].content_mc.base_mc.width != w || this["pane" + id + "_mc"].content_mc.base_mc.height != h)
  321.    {
  322.       this.sizeMe(w,h,this["pane" + id + "_mc"].content_mc.base_mc);
  323.    }
  324.    if(this["pane" + id + "_mc"].titlebar_mc.width != w)
  325.    {
  326.       this.sizeMe(w,this["pane" + id + "_mc"].titlebar_mc._height,this["pane" + id + "_mc"].titlebar_mc);
  327.    }
  328.    this["pane" + id + "_mc"].label_mc.mask_mc._width = w - 4;
  329.    this.drawBox("mask_mc",-1,this.pad,this.pad,w - this.pad * 2,h - this.pad * 2,0,0,this["pane" + id + "_mc"].content_mc);
  330.    this["pane" + id + "_mc"].content_mc.holder_mc.setMask(this["pane" + id + "_mc"].content_mc.mask_mc);
  331.    !this["pane" + id + "_mc"].expanded ? this.collapse(id) : this.expand(id);
  332. };
  333. GWCollapsiblePaneClass.prototype.getPaneLabel = function(i)
  334. {
  335.    return this["pane" + i + "_mc"].label_mc.label_txt.text;
  336. };
  337. GWCollapsiblePaneClass.prototype.setPaneLabel = function(l, i)
  338. {
  339.    this["pane" + i + "_mc"].createEmptyMovieClip("label_mc",1);
  340.    this["pane" + i + "_mc"].label_mc.createTextField("label_txt",2,0,0,this.width,this.height);
  341.    var _loc3_ = new TextFormat();
  342.    _loc3_.font = this.font;
  343.    _loc3_.size = this.fontsize;
  344.    _loc3_.color = this.fontcolor;
  345.    _loc3_.bold = false;
  346.    this["pane" + i + "_mc"].label_mc.label_txt.autoSize = "center";
  347.    this["pane" + i + "_mc"].label_mc.label_txt.selectable = false;
  348.    if(this.useEmbedFonts)
  349.    {
  350.       this["pane" + i + "_mc"].label_mc.label_txt.embedFonts = true;
  351.    }
  352.    this["pane" + i + "_mc"].label_mc.label_txt.html = true;
  353.    this["pane" + i + "_mc"].label_mc.label_txt.htmlText = this.panes[i].label = l;
  354.    this["pane" + i + "_mc"].label_mc.label_txt.setTextFormat(_loc3_);
  355. };
  356.